package com.dream.keigezhushou.Activity.Fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;

import com.dream.keigezhushou.Activity.Uiutils.StringUtils;
import com.dream.keigezhushou.Activity.Uiutils.UiUtils;
import com.dream.keigezhushou.Activity.kege.acty.SingingDetailActivity;
import com.dream.keigezhushou.Activity.kege.adapter.MyKeAdapter;
import com.dream.keigezhushou.Activity.kege.adapter.SingRankingAdapter;
import com.dream.keigezhushou.R;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshListView;

/**
 * k歌排行榜
 */
public class KeRankingFragment extends Fragment {
    private PullToRefreshListView mMPullToRefreshListView;
    private ListView mListlv;
    private Intent intent;
    private SingRankingAdapter adapter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initData();
        //getDataFromService();   获取网络数据并解析
        // 加载动画
        //设置上拉刷新重新请求网络数据  更新adapter?
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mMPullToRefreshListView = (PullToRefreshListView) UiUtils.inflateView(R.layout.kege_fragment);
        mListlv = mMPullToRefreshListView.getRefreshableView();
        initView();
        return mMPullToRefreshListView;
    }

    private void initView() {
        adapter = new SingRankingAdapter(getContext(), 0);
        mListlv.setAdapter(adapter);

        adapter.setItemOnClickListening(new SingRankingAdapter.ItemOnClickListening() {
            @Override
            public void itemClick(int postion) {
                adapter.setItemOnClickListening(new SingRankingAdapter.ItemOnClickListening() {
                    @Override
                    public void itemClick(int postion) {
                        Intent intent = new Intent();
                        intent.putExtra(StringUtils.KEGESTATE, "Ｋ歌");
                        intent.setClass(getContext(), SingingDetailActivity.class);
                        startActivity(intent);
                    }
                });

            }
        });


    }

    private void initData() {


    }


}
